/*************************************************************************
* TinySG, Copyright (C) 2007, 2008  J.D. Yamokoski
* All rights reserved.
* Email: yamokosk at gmail dot com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version. The text of the GNU Lesser General
* Public License is included with this library in the file LICENSE.TXT.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE.TXT for
* more details.
*
*************************************************************************/

/*
 * Code taken from the Orca-Robotics Project
 * http://orca-robotics.sf.net/
 */

#ifndef DYNAMICLOAD_DLL_H
#define DYNAMICLOAD_DLL_H

#include <string>

namespace obrsp {

namespace plugin {

//!
//! Class to encapsulate a dynamically-loaded library, so you can load
//! code at run-time.
//!
//! Note that you have to keep this thing in scope for as long as you
//! want to access code from it.
//!
class DynamicLibrary
{
public:
	static DynamicLibrary * load(const std::string& path, std::string& errorString);

	 ~DynamicLibrary();

	void * getSymbol(const std::string & name);

private:
	DynamicLibrary();

	DynamicLibrary(void * handle);
	DynamicLibrary(const DynamicLibrary &);

private:
	void * handle_;
};

}  // namespace plugin

}  // namespace obrsp
#endif
